import type{App} from 'vue'
import pinia from '@/stores'
import {useUserInfoStore} from '@/stores/userInfo'
export default (app:App) => {
  const userInfoStore = useUserInfoStore(pinia)
  //指令函数中区判断 仅仅是在挂载阶段去使用效率更高
  app.directive('has',{
    mounted(el,bindings){
      let exisBtn = userInfoStore.userInfo.buttons.includes(bindings.value)
      if(!exisBtn){
        el.parentNode.removeChild(el)
      }
    }
   })
  }
  //(el,bindings)=>{
  // // 查找返回的数据中按钮是否存，不在的话就根据其父元素去删除
  //   let exisBtn = userInfoStore.userInfo.buttons.includes(bindings.value)
  // if(!exisBtn){
  //   el.parentNode.removeChild(el)
  // }
  // })

// 再去main.js中区注册